package cn.ruihusoft.ql.service.impl;

import cn.hutool.core.collection.ListUtil;
import cn.ruihusoft.ql.client.EnvClient;
import cn.ruihusoft.ql.pojo.env.AddEnvRequest;
import cn.ruihusoft.ql.pojo.env.EnvDetailResponse;
import cn.ruihusoft.ql.pojo.env.UpdateEnvRequest;
import cn.ruihusoft.ql.service.EnvService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class EnvServiceImpl implements EnvService {

    @Autowired
    private EnvClient envClient;

    @Override
    public List<EnvDetailResponse> allEnvs() {
        return envClient.allEnvs().getData();
    }

    @Override
    public List<EnvDetailResponse> addEnvs(List<AddEnvRequest> envs) {
        return envClient.addEnvs(envs).getData();
    }

    @Override
    public void updateEnv(UpdateEnvRequest env) {
        envClient.updateEnv(env);
    }

    @Override
    public void enableEnv(Integer envId) {
        envClient.enable(ListUtil.of(envId));
    }

    @Override
    public void enableEnv(List<Integer> envIds) {
        envClient.enable(envIds);
    }
}
